package word

import (
	"gin/tai"
	tccommon "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common"
	nlp "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/nlp/v20190408"
)

func Select(dictId *string, limit *uint64, offset *uint64, keyword *string) (*nlp.DescribeWordItemsResponse, error) {
	client, _ := tai.GetNlpClient()
	request := nlp.NewDescribeWordItemsRequest()
	request.DictId = dictId
	request.Limit = limit
	request.Offset = offset
	if *keyword != "" {
		request.Text = keyword
	}
	return client.DescribeWordItems(request)
}

func Create(dictId string, wordItems *[]*nlp.WordItem) (*nlp.CreateWordItemsResponse, error) {
	client, _ := tai.GetNlpClient()
	request := nlp.NewCreateWordItemsRequest()
	request.WordItems = *wordItems
	request.DictId = tccommon.StringPtr(dictId)
	return client.CreateWordItems(request)
}

func Delete(dictId string, wordItems *[]*nlp.WordItem) (*nlp.DeleteWordItemsResponse, error) {
	client, _ := tai.GetNlpClient()
	request := nlp.NewDeleteWordItemsRequest()
	request.WordItems = *wordItems
	request.DictId = tccommon.StringPtr(dictId)
	return client.DeleteWordItems(request)
}

func Find(dictId string, wordItem []*nlp.WordItem) (*nlp.SearchWordItemsResponse, error) {
	client, _ := tai.GetNlpClient()
	request := nlp.NewSearchWordItemsRequest()
	request.WordItems = wordItem
	request.DictId = tccommon.StringPtr(dictId)
	return client.SearchWordItems(request)
}

// 查询相似词
func Similar(word string, wordNumber uint64) (*nlp.SimilarWordsResponse, error) {
	client, _ := tai.GetNlpClient()
	request := nlp.NewSimilarWordsRequest()
	request.Text = &word
	request.WordNumber = &wordNumber
	return client.SimilarWords(request)
}
